<?php

require_once dirname(__FILE__) . '/OauthMethod.php';
require_once dirname(__FILE__) . '/UploadedImages.php';

/**
 * Base class to upload images to server within call of some API methods like:
 * [ads/new], [ads.images/add].
 * 
 * @see GG_API_MethodAdsNew
 * @see GG_API_MethodAdsImagesAdd
 */
class GG_API_UploadImagesMethod extends GG_API_OauthMethod {

	/**
	 * @param array $config
	 */
	public function __construct($config = null) {
		parent::__construct($config);
	}

	/**
	 * Reads uploaded image files and encode them so they can be passed to GG
	 * API method. Array of encoded images will be used as value for API param
	 * "imageDatas". Encoding of read content of every image done in two steps:
	 * base64_encode(), then urlencode().
	 *
	 * @param string $inputName Name of parameter used to upload image
	 *     files with HTML tag type=file. E.g. if images were uploaded with tag
	 *     <input type="file" name="images[]"/> then $inputName is "images".
	 *
	 * @see GG_API_UploadedImages::getEncodedDatas()
	 */
	public function setParamImageDatasByInputName($inputName = "images") {
		$imageDatas = GG_API_UploadedImages::getEncodedDatas($inputName);
		$this->setParam("imageDatas", $imageDatas);
	}
}

?>
